#if MSC_VER >=1000
    #pragma execution_character_set("UTF-8")
#endif

#include "lyric.h"
#include<QTextStream>
#include<QJsonDocument>
#include<QJsonObject>
#include<QJsonParseError>
#include<QDebug>


// 返回测试命名空间的 数据
QString Test_music::get_src(){
    return test_src;
}

Lyric::Lyric()
{

}

Lyric Lyric::parseFromJson(QString jstr)
{
    Lyric lyric;

   QJsonDocument doc = QJsonDocument::fromJson(jstr.toLocal8Bit().data());

   if(doc.isNull()){
       qDebug()<<"JSONString null";
       return lyric;
   }

   QJsonObject jsonObject = doc.object();
   qDebug()<<jsonObject;

   auto scode = jsonObject.value("code");
   auto olyric = jsonObject.value("lrc");

    qDebug()<<"olyric"<<olyric;
   auto sqfy= jsonObject.value("qfy");
   auto ssfy = jsonObject.value("sfy");
   auto ssgc = jsonObject.value("sgc");

   auto otlyric = jsonObject.value("tlyric");




   // 设置属性
    lyric.setSgc(ssgc.toBool());
    lyric.setSfy(ssfy.toBool());
    lyric.setCode(scode.toInt());

    lyric.setTLyric(Tlyric::parseFromJSON(olyric.toObject()));
   return lyric;

}

void Lyric::setSgc(bool sgc)
{
    this->sgc = sgc;

}

void Lyric::setSfy(bool sfy)
{
    this->sfy = sfy;
}

void Lyric::setLrc(Lrc lrc)
{
    this->lrc = lrc;
}

void Lyric::setTLyric(Tlyric tlyric)
{
    this->tlyric = tlyric;
}

void Lyric::setCode(int code)
{
    this->code = code;

}

Lrc Lyric::getLrc()
{
    return this->lrc;
}

Tlyric Lyric::getTlyric()
{
    return this->tlyric;
}

int Lyric::getCode()
{
    return this->code;
}

void Lyric::info()
{
    qDebug()<<"{sgc"<<this->sgc<<" , sfy:"<<this->sfy<<" , lrc:"<<this->getLrc().getLyric()<<
             "{tlyric:"<<this->getTlyric().getLyric() <<", version "<<this->getTlyric().getVersion() <<" } ,code: "
           <<this->getCode()<<"}";

}
